package com.itany.corejava.code14_lambda;

import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;

/**
 * @author MissChen
 * @date 2024年03月25日 14:01
 */
public class Test03_供给型接口 {
    public static void main(String[] args) {
       // List<String> list= testSupplier(new Supplier<List<String>>() {
       //      @Override
       //      public List<String> get() {
       //          return Arrays.asList("小王","大王","花花","嘻嘻");
       //      }
       //  });
       //  System.out.println(list);

        //Lambda表达式
        List<String> list=testSupplier(()->Arrays.asList("小王","大王","花花","嘻嘻"));
        System.out.println(list);

    }

    /**
     * 供给型接口Supplier<T>，T get()
     * 接口有返回值，其接口泛型类型与方法返回值类型一致
     * @param supplier
     * @return
     */
    public static List<String> testSupplier(Supplier<List<String>> supplier){
        return supplier.get();
    }
}
